﻿using PLCTest.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PLCTest.BO
{
    public class ZJNDoubleScMessageWcsActionBO
    {
        /// <summary>
        /// 启动命令
        /// </summary>
        public bool Startcommand { get; set; }
        /// <summary>
        /// 报警复位
        /// </summary>
        public bool Alarmreset { get; set; }
        /// <summary>
        /// 自动任务复位
        /// </summary>
        public bool Taskreset { get; set; }
        /// <summary>
        /// WCS消防命令
        /// </summary>
        public bool WCSfirecommand { get; set; }

        /// <summary>
        /// WCS拍照温度无异常
        /// </summary>
        public bool WCSfireOK { get; set; }
        /// <summary>
        /// WCS拍照温度异常
        /// </summary>
        public bool WCSfireNG { get; set; }
        /// <summary>
        /// WCS拍照人工确认
        /// </summary>
        public bool WCSfireAffirm { get; set; }

        /// <summary>
        /// 手动任务复位
        /// </summary>
        public bool ManualTaskreset { get; set; }

        /// <summary>
        /// 1号叉工作序号
        /// </summary>
        public int JobOnenumber { get; set; }
        /// <summary>
        /// 工作命令代码
        /// </summary>
        public short Jobordercode { get; set; }
        /// <summary>
        /// 1号叉启始行fromPC
        /// </summary>
        public short StartOnelinefromPC { get; set; }
        /// <summary>
        /// 1号叉启始列fromPC
        /// </summary>
        public short StartOnecolumnfromPC { get; set; }
        /// <summary>
        /// 1号叉启始层fromPC
        /// </summary>
        public short StartOnelayerfromPC { get; set; }
        /// <summary>
        /// 1号叉目标行fromPC
        /// </summary>
        public short TargetOnelinefromPC { get; set; }
        /// <summary>
        /// 1号叉目标列fromPC
        /// </summary>
        public short TargetOnecolumnfromPC { get; set; }
        /// <summary>
        /// 1号叉目标层fromPC
        /// </summary>
        public short TargetOnelayerfromPC { get; set; }
        /// <summary>
        /// WCS过账完成
        /// </summary>
        public short WCSpostingcompleted { get; set; }

        public short yuliu8 { get; set; }
        /// <summary>
        /// 心跳信号
        /// </summary>
        public short HeartBeat { get; set; }
        public short yuliu10 { get; set; }
        public short yuliu11 { get; set; }
        public short yuliu12 { get; set; }

        public bool beiyong1 { get; set; }

        public bool beiyong2 { get; set; }

        public bool beiyong3 { get; set; }

        public int beiyong4 { get; set; }

        public int beiyong5 { get; set; }

        public int beiyong6 { get; set; }

        public int beiyong7 { get; set; }

        public int beiyong8 { get; set; }

        public int beiyong9 { get; set; }

        public int beiyong10 { get; set; }


        /// <summary>
        /// 2号叉工作序号
        /// </summary>
        public int JobTwonumber { get; set; }

        /// <summary>
        /// 2号叉启始行fromPC
        /// </summary>
        public short StartTwolinefromPC { get; set; }
        /// <summary>
        /// 2号叉启始列fromPC
        /// </summary>
        public short StartTwocolumnfromPC { get; set; }
        /// <summary>
        /// 2号叉启始层fromPC
        /// </summary>
        public short StartTwolayerfromPC { get; set; }
        /// <summary>
        /// 2号叉目标行fromPC
        /// </summary>
        public short TargetTwolinefromPC { get; set; }
        /// <summary>
        /// 2号叉目标列fromPC
        /// </summary>
        public short TargetTwocolumnfromPC { get; set; }
        /// <summary>
        /// 2号叉目标层fromPC
        /// </summary>
        public short TargetTwolayerfromPC { get; set; }

        /// <summary>
        /// 取1货叉选择 0复位  1 1号货叉 2 2号货叉  3  双货叉
        /// </summary>
        public short StartOnePalletForkChoice { get; set; }

        /// <summary>
        /// 取2货叉选择 0复位  1 1号货叉 2 2号货叉  3  双货叉
        /// </summary>
        public short StartTwoPalletForkChoice { get; set; }

        /// <summary>
        /// 放1货叉选择 0复位  1 1号货叉 2 2号货叉  3  双货叉
        /// </summary>
        public short TargetOnePalletForkChoice { get; set; }

        /// <summary>
        /// 放2货叉选择 0复位  1 1号货叉 2 2号货叉  3  双货叉
        /// </summary>
        public short TargetTwoPalletForkChoice { get; set; }

        //public short beiyong11 { get; set; }

        ///// <summary>
        ///// 1号货叉托盘条码
        ///// </summary>
        //public string PalletBarcode1 { get; set; }

        ///// <summary>
        ///// 2号货叉托盘条码
        ///// </summary>
        //public string PalletBarcode2 { get; set; }


        public void Serialize(byte[] bytes)
        {
            //PlcConnectionID = plcConnectionID;
            //PlcReadDbID = plcReadDbID;
            //BytesIndex = bytesIndex;
            //BytesLength = bytesLength;
            //ObjectIndex = objectIndex;
            //ObjectLength = objectLength;
            ///// <summary>
            ///// 约定：
            ///// 1、设备状态报文以State结尾；
            ///// 2、Plc的动作报文以PlcAction结尾；
            ///// 3、Wcs的动作报文以WcsAction结尾；
            ///// 4、平面PLC报文统一PlcState名称
            ///// （后续有其他的再约定）
            ///// </summary>
            //ObjectType = objectType;
            //EquipmentCode = ScEquipmentCode;

            Startcommand = HelperByte.GetBitAt(bytes, 0, 0);
            Alarmreset = HelperByte.GetBitAt(bytes, 0, 1);
            Taskreset = HelperByte.GetBitAt(bytes, 0, 2);
            WCSfirecommand = HelperByte.GetBitAt(bytes, 0, 3);
            WCSfireOK = HelperByte.GetBitAt(bytes, 0, 4);
            WCSfireNG = HelperByte.GetBitAt(bytes, 0, 5);
            WCSfireAffirm = HelperByte.GetBitAt(bytes, 0, 6);
            ManualTaskreset = HelperByte.GetBitAt(bytes, 0, 7);


            JobOnenumber = HelperByte.GetDIntAt(bytes, 2);
            Jobordercode = HelperByte.GetIntAt(bytes, 6);
            StartOnelinefromPC = HelperByte.GetIntAt(bytes, 8);
            StartOnecolumnfromPC = HelperByte.GetIntAt(bytes, 10);
            StartOnelayerfromPC = HelperByte.GetIntAt(bytes, 12);
            TargetOnelinefromPC = HelperByte.GetIntAt(bytes, 14);
            TargetOnecolumnfromPC = HelperByte.GetIntAt(bytes, 16);
            TargetOnelayerfromPC = HelperByte.GetIntAt(bytes, 18);
            WCSpostingcompleted = HelperByte.GetIntAt(bytes, 20);
            yuliu8 = HelperByte.GetIntAt(bytes, 22);
            HeartBeat = HelperByte.GetIntAt(bytes, 24);
            yuliu10 = HelperByte.GetIntAt(bytes, 26);
            yuliu11 = HelperByte.GetIntAt(bytes, 28);
            yuliu12 = HelperByte.GetIntAt(bytes, 30);

            beiyong1 = HelperByte.GetBitAt(bytes, 32, 0);
            beiyong2 = HelperByte.GetBitAt(bytes, 32, 1);
            beiyong3 = HelperByte.GetBitAt(bytes, 32, 2);
            beiyong4 = HelperByte.GetDIntAt(bytes, 34);
            beiyong5 = HelperByte.GetDIntAt(bytes, 38);
            beiyong6 = HelperByte.GetDIntAt(bytes, 42);
            beiyong7 = HelperByte.GetDIntAt(bytes, 46);
            beiyong8 = HelperByte.GetDIntAt(bytes, 50);
            beiyong9 = HelperByte.GetDIntAt(bytes, 54);
            beiyong10 = HelperByte.GetDIntAt(bytes, 58);

            JobTwonumber = HelperByte.GetDIntAt(bytes, 62);
            StartTwolinefromPC = HelperByte.GetIntAt(bytes, 66);
            StartTwocolumnfromPC = HelperByte.GetIntAt(bytes, 68);
            StartTwolayerfromPC = HelperByte.GetIntAt(bytes, 70);
            TargetTwolinefromPC = HelperByte.GetIntAt(bytes, 72);
            TargetTwocolumnfromPC = HelperByte.GetIntAt(bytes, 74);
            TargetTwolayerfromPC = HelperByte.GetIntAt(bytes, 76);

            StartOnePalletForkChoice = HelperByte.GetIntAt(bytes, 78);
            StartTwoPalletForkChoice = HelperByte.GetIntAt(bytes, 80);
            TargetOnePalletForkChoice = HelperByte.GetIntAt(bytes, 82);
            TargetTwoPalletForkChoice = HelperByte.GetIntAt(bytes, 84);


            //beiyong11 = HelperByte.GetIntAt(bytes, 86);
            ////托盘长度
            //int length1 = HelperByte.GetSIntAt(bytes, 89);
            //PalletBarcode1 = HelperByte.GetCharsAt(bytes, 90, length1);
            //int length2 = HelperByte.GetSIntAt(bytes, 121);
            //PalletBarcode2 = HelperByte.GetCharsAt(bytes, 122, length2);
        }

    }
}
